package org.ilovecode.buttons
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import org.ilovecode.mvc.View;
	
	public class Button extends View
	{
		protected var _enabled:Boolean;
		
		public function Button(name:String="", enabled:Boolean = true)
		{
			super(name);
			
			_enabled = enabled;
		}
		
		override protected function construct():void
		{
			super.construct();
			
			this.mouseEnabled = this.buttonMode = true;
		}
		
		override protected function addListeners():void
		{
			super.addListeners();
			this.addEventListener(MouseEvent.CLICK, handle_Click);
			this.addEventListener(MouseEvent.MOUSE_OVER, handle_MouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, handle_MouseOut);
		}
		
		override protected function removeListeners():void
		{
			super.removeListeners();
			this.removeEventListener(MouseEvent.CLICK, handle_Click);
			this.removeEventListener(MouseEvent.MOUSE_OVER, handle_MouseOver);
			this.removeEventListener(MouseEvent.MOUSE_OUT, handle_MouseOut);
		}
		
		protected function handle_Click(event:MouseEvent):void
		{
			//Implement in child method
		}
		
		protected function handle_MouseOver(event:MouseEvent):void
		{
			//Implement in child method
		}
		
		protected function handle_MouseOut(event:MouseEvent):void
		{
			//Implement in child method
		}

		public function get enabled():Boolean
		{
			return this._enabled;
		}
		
		public function set enabled(value:Boolean):void
		{
			this._enabled = this.mouseEnabled = this.buttonMode = value;
		}

		
	}
}